package pers.cj.pdos.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;

public class FileProperUtil {
    private static FileProperUtil fileProperUtil;

    private Properties properties;
    private FileProperUtil() throws IOException {
        properties = new Properties();
        InputStream inputStream = this.getClass().getResourceAsStream("/file.properties");
        properties.load(inputStream);
    }

    public static FileProperUtil getInstance() throws IOException {
        if (fileProperUtil == null) {
            fileProperUtil = new FileProperUtil();
        }
        return fileProperUtil;
    }

    public String getVal(String key) {
        return properties.getProperty(key);
    }
    public List<String> propertyNames() {
        List<String> list = new ArrayList<>();
        Enumeration<?> enu = properties.propertyNames();
        while (enu.hasMoreElements()) {
            String key = (String) enu.nextElement();
            list.add(key);
        }
        return list;
    }
}
